<?php

namespace App\Models;

use Illuminate\Database\Eloquent\SoftDeletes;

class Order extends BaseModel
{
//    use SoftDeletes;
    public $table = 'order';
    public $timestamps = true;
    static $unguarded = true;

    const CREATED_AT = 'create_time';
    const UPDATED_AT = 'update_time';

    /**
     * 获取当前时间
     *
     * @return int
     */
    public function freshTimestamp()
    {
        return time();
    }

    /**
     * 避免转换时间戳为时间字符串
     *
     * @param DateTime|int $value
     * @return DateTime|int
     */
    public function fromDateTime($value)
    {
        return $value;
    }

    static function getOrderStatus($status)
    {

        $arr = [
            1 => "待付款",
            10 => "进行中",
            20 => "已完成",
            60 => "已退款",
            80 => "已经取消",
        ];

        return isset($status) ? $arr[$status] : $arr;
    }

    //配送状态
    static function deliverStatus($v = "")
    {
        $arr = [
            1 => "待接单",
            2 => "待取货",
            3 => "配送中",
            4 => "已完成"
        ];

        return isset($arr[$v]) ? $arr[$v] : (count(func_get_args()) == 0 ? $arr : '');
    }

    //发货状态
    static function deliveryStatus($v = "")
    {
        $arr = [
            10 => "未发货",
            20 => "已发货"
        ];
        return isset($arr[$v]) ? $arr[$v] : (count(func_get_args()) == 0 ? $arr : '');
    }

    //收货状态
    static function receiptStatus($v = "")
    {
        $arr = [
            10 => "未收货",
            20 => "已收货"
        ];
        return isset($arr[$v]) ? $arr[$v] : (count(func_get_args()) == 0 ? $arr : '');
    }

}